package com.lzb.play.adapter;


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.lzb.play.R;
import com.lzb.play.bean.HomeBirdBean;
import com.youth.banner.adapter.BannerAdapter;
import com.youth.banner.util.BannerUtils;

import java.util.List;


public class MyBannerAdapter extends BannerAdapter<HomeBirdBean, MyBannerAdapter.ImageTitleHolder> {

    Context context;

    public MyBannerAdapter(List<HomeBirdBean> datas, Context context) {
        super(datas);
        this.context = context;
    }

    @Override
    public ImageTitleHolder onCreateHolder(ViewGroup parent, int viewType) {
        return new ImageTitleHolder(BannerUtils.getView(parent, R.layout.item_banner));
    }

    @Override
    public void onBindView(ImageTitleHolder holder, HomeBirdBean data, int position, int size) {
        holder.ivBannerItemImg.setImageResource(data.getImg());
        holder.tvBannerItemName.setText(data.getBirdBean().getName());
        holder.tvBannerItemAlias.setText(context.getString(R.string.alias_tip) + data.getBirdBean().getAlias());
    }

    public class ImageTitleHolder extends RecyclerView.ViewHolder {
        public ImageView ivBannerItemImg;
        public TextView tvBannerItemName, tvBannerItemAlias;

        public ImageTitleHolder(@NonNull View view) {
            super(view);
            ivBannerItemImg = view.findViewById(R.id.ivBannerItemImg);
            tvBannerItemName = view.findViewById(R.id.tvBannerItemName);
            tvBannerItemAlias = view.findViewById(R.id.tvBannerItemAlias);
        }
    }
}
